home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
wtek0693.zip
/
OOPALLEY.ZIP
/
XQUEUE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-27
|
3KB
|
108 lines
//#include <stream.h>
#define DISPLAY_ARRAYOB_INFO
#ifdef DISPLAY_ARRAYOB_INFO
#include "arrayob.h"
#endif
#include "queue.h"
#if 1
// required only by test application
#include "point.h"
#include "conio.h"
#endif
void printRemove(Queue& q)
{
cout << "Remove and print each object in Queue:\n";
while(q.size()>0)
{
cout << *q.next();
cout << " | ";
}
cout << "=======\n";
}
#pragma argsused
// q is used with preprocessor sizeof operator
// but BC++ 3.1 reports that q is not used
// The above pragma turns off the warning.
void printObjectSizes(Queue& q)
{
cout << "sizeof(q):" << sizeof(q) << "\n";
cout << "sizeof(Object):" << sizeof(Object) << "\n";
cout << "sizeof(Point):" << sizeof(Point) << "\n";
cout << "sizeof(Queue):" << sizeof(Queue) << "\n";
#ifdef DISPLAY_ARRAYOB_INFO
cout << "sizeof(ArrayOb):" << sizeof(ArrayOb) << "\n";
#endif
}
#define BATCH
#ifdef BATCH
// useful for batch output verification
inline int getch() // don't wait for keypress
{
cout << "========================================\n";
return 0;
}
#endif
main()
{
cout << "hello, world\n";
Queue q(10);
cout << "q created\n";
cout << "q capacity: " << q.capacity() << "\n";
cout << "q size: " << q.size() << "\n";
printObjectSizes(q);
getch();
for (int i=0; i<2; i++)
{
q.nextPut(*new Point(i,1));
q.nextPut(*new Point(i,2));
q.nextPut(*new Point(i,3));
q.state(); printRemove(q); getch();
q.nextPut(*new Point(i,4));
q.nextPut(*new Point(i,5));
q.nextPut(*new Point(i,6));
q.nextPut(*new Point(i,7));
q.nextPut(*new Point(i,8));
q.nextPut(*new Point(i,9));
q.nextPut(*new Point(i,10));
cout << "q should be filled:\n";
q.state(); printRemove(q); getch();
}
i = 3;
q.nextPut(*new Point(i,1));
q.nextPut(*new Point(i,2));
q.nextPut(*new Point(i,3));
q.state(); q.printOn(cout); getch();
q.nextPut(*new Point(i,4));
q.nextPut(*new Point(i,5));
q.nextPut(*new Point(i,6));
q.nextPut(*new Point(i,7));
q.nextPut(*new Point(i,8));
q.nextPut(*new Point(i,9));
q.nextPut(*new Point(i,10));
q.state(); q.printOn(cout);
cout << "Next statement should resize q\n";
getch();
q.nextPut(*new Point(i,11));
q.state(); getch(); printRemove(q); getch();
return 0;
}